/**     
* @Title: MyInvocationSecurityMetadataSourceService.java   
* @Package me.springboot.security.access.intercept   
* @Description: TODO   
* @author xaoyaoyao
* @date 2017年8月25日 下午10:57:09
*/  
package me.springboot.security.access.intercept;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.web.FilterInvocation;
import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
import org.springframework.stereotype.Service;

import me.springboot.security.MyConfigAttribute;

/**   
* @ClassName: MyInvocationSecurityMetadataSourceService   
* @Description: TODO   
* @author xaoyaoyao
* @date 2017年8月25日 下午10:57:09   
*      
*/
@Service
public class MyInvocationSecurityMetadataSourceService implements FilterInvocationSecurityMetadataSource {

	@Override
	public Collection<ConfigAttribute> getAllConfigAttributes() {
		return null;
	}

	@Override
	public Collection<ConfigAttribute> getAttributes(Object object) throws IllegalArgumentException {
		final HttpServletRequest request = ((FilterInvocation) object).getRequest();
		Set<ConfigAttribute> allAttributes = new HashSet<ConfigAttribute>();
		ConfigAttribute configAttribute = new MyConfigAttribute(request);
		allAttributes.add(configAttribute);
		return allAttributes;
	}

	@Override
	public boolean supports(Class<?> arg0) {
		return true;
	}
}